﻿@using Bonobo.Git.Server.Extensions
@using MvcCheckBoxList.Model
@model Bonobo.Git.Server.Models.RepositoryDetailModel
@{
    ViewBag.Title = Resources.Repository_Create_Title;
}
<h1>@Resources.Repository_Create_Title</h1>

@using (Html.BeginForm("Create", "Repository", FormMethod.Post, new { @class = "pure-form pure-form-aligned", enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(false, Resources.Repository_Create_Fail)
    
    <fieldset>
        <div class="pure-control-group">
            @Html.LabelFor(m => m.Name)
            @Html.TextBoxFor(m => m.Name, new {autofocus = ""})<em>*</em>
            @Html.ValidationMessageFor(m => m.Name)
        </div>
        <div class="pure-control-group">
            @Html.LabelFor(m => m.Group)
            @Html.TextBoxFor(m => m.Group, new { @class = "medium" })
        </div>
        <div class="pure-control-group">
            @Html.LabelFor(m => m.Description)
            @Html.TextAreaFor(m => m.Description, new { @class = "medium" })
        </div>
        <div class="pure-control-group">
            @Html.LabelFor(m => m.Logo.PostedFile)
            <input type="file" name="Logo.PostedFile" id="Logo_PostedFile" />
            <sup>.png, .jpg, .jpeg, .gif</sup>
        </div>

            <div class="pure-control-group">
                @Html.LabelFor(m => m.AllowAnonymous)
                @Html.CheckBoxFor(m => m.AllowAnonymous, new { @onClick = "document.getElementById('AllowAnonymousPush').disabled = !this.checked" })
                <i class="fa fa-info-circle" title="@Resources.Repository_AllowAnonymousHint"></i>
            </div>

            <div class="pure-control-group">
                @Html.LabelFor(m => m.AllowAnonymousPush)
                @{
                    object attribs = new { @id = "AllowAnonymousPush" };
                    if (!Model.AllowAnonymous){
                        attribs = new { @id = "AllowAnonymousPush", @disabled = "" }; 
                    }
                }
                @Html.EnumDropDownListFor(m => m.AllowAnonymousPush, attribs)
                <i class="fa fa-info-circle" title="@Resources.Repository_AllowAnonymousPushHint"></i>
            </div>
        <div class="pure-control-group">
            @Html.LabelFor(m => m.LinksUseGlobal)
            @Html.CheckBoxFor(m => m.LinksUseGlobal, new { @onClick = "document.getElementById('LinksRegex').disabled = this.checked; document.getElementById('LinksUrl').disabled = this.checked" })
        </div>
        <div class="pure-control-group">
            @Html.LabelFor(m => m.LinksRegex)
            @{
                attribs = new { @class = "medium" };
                if (Model.LinksUseGlobal){
                    attribs = new { @class = "medium", disabled = "" };
                }
                @Html.TextBoxFor(m => m.LinksRegex, attribs);
                @Html.ValidationMessageFor(m => m.LinksRegex);
            }
        </div>
        <div class="pure-control-group">
            @Html.LabelFor(m => m.LinksUrl)
            @Html.TextBoxFor(m => m.LinksUrl, attribs)
            <i class="fa fa-info-circle" title="@Resources.Settings_Global_LinksUrl_Hint"></i>
        </div>
            <div class="pure-control-group checkboxlist">
                @Html.LabelFor(m => m.Users)
                <span>
                    @Html.CheckBoxListFor(m => m.PostedSelectedUsers, mm => mm.AllUsers, mm => mm.Id, mm => mm.DisplayName, mm => mm.Users, Position.Vertical)
                </span>
                <i class="fa fa-info-circle" title="@Resources.Repository_UsersHint"></i>
            </div>

            <div class="pure-control-group checkboxlist">
                @Html.LabelFor(m => m.Administrators)
                <span>
                    @Html.CheckBoxListFor(m => m.PostedSelectedAdministrators, mm => mm.AllAdministrators, mm => mm.Id, mm => mm.DisplayName, mm => mm.Administrators, Position.Vertical)
                </span>
                @Html.ValidationMessageFor(m => m.Administrators)
                <i class="fa fa-info-circle" title="@Resources.Repository_AdministratorsHint"></i>
            </div>

            <div class="pure-control-group checkboxlist">
                @Html.LabelFor(m => m.Teams)
                <span>
                    @Html.CheckBoxListFor(m => m.PostedSelectedTeams, mm => mm.AllTeams, mm => mm.Id, mm => mm.DisplayName, mm => mm.Teams, Position.Vertical)
                </span>
                <i class="fa fa-info-circle" title="@Resources.Repository_TeamsHint"></i>
            </div>



            <div class="pure-controls">
                <a class="pure-button" href="@Url.Action("Index")"><i class="fa fa-long-arrow-left"></i> @Resources.Repository_Back</a>
                <button type="submit" class="pure-button pure-button-primary"><i class="fa fa-save"></i> @Resources.Repository_Create_Submit</button>
            </div>
</fieldset>
}
